#!/bin/bash
#
#
#
#
#while true 
#do 
clear 
echo -e "\t\t\t\e[42;31msinger menu\e[0m\t\t\t"
echo -e "\n\t\t\t\e[41;30m1.display singer\e[0m\t\t\t\t"
echo -e "\n\t\t\t\e[41;30m2.begin singing\e[0m\t\t\t\t"
echo -e "\n\t\t\t\e[41;30m3.exit\e[0m\t\t\t\t"
echo -e "\nplease input your option:" 
read 			option

singer=(`cat singer.txt`)
songs=(`cat songslist.txt`)
num=`cat singer.txt|wc -w`
song_num=`cat songslist.txt|wc -w`

case $option in 

(1)
	echo -e "the singers who should sing for us are:\033[33m${singer[@]}\033[0m,total is: \033[32m$num\033[0m"
	echo -e "the songs we can chosed are:\033[33m${songs[@]}\033[0m,total is: \033[32m$song_num\033[0m"
	;;


(2)
	singer=(`cat singer.txt`)
	songs=(`cat songslist.txt`)
	len=${#singer[@]}
	lucky_num=$((RANDOM%len))
	song_len=${#songs[@]}
	song_lucky_num=$(( RANDOM%song_len ))
	echo -e "\033[39mwho will be expected to be singing for us,let us look forward...\033[0m"
# set time delay

	for i in 3 2 1
	do
		echo -e "\t\t\t\t\033[45;34m$i\033[0m" 
		sleep 1
	done
	echo -e  "\nplease singer ${singer[lucky_num]} sing for us ${songs[song_lucky_num]}" 
	unset singer[lucky_num]
	echo ${singer[@]} >singer.txt
	unset songs[song_lucky_num]
	echo ${songs[@]} >songslist.txt
	echo -e "\n\e[42;29m no singing singer are:${singer[@]}\e[0m"
	num=`cat singer.txt |wc -w`
	echo -e "\n\e[42;29mno singing songs are: ${songs[@]}\e[0m"




	if (( num==0 ))
	then
		read -p "now all singer already sang,again" again
     		/bin/cp singer_bak.txt  singer.txt
		read -p "now songs will restart!"
		/bin/cp songslist_bak.txt songslist.txt
	fi

	;;
(3)
	exit
	;;	

esac
#done
